<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <form action="http://localhost/register" method="post">
        用户名称：<input type="text" name="username" id=""><br>
        用户密码：<input type="password" name="password" id=""><br>
        确认密码：<input type="password" name="repwd" id=""><span></span><br>
        <% if(msgg){%>
            <span>
                <%=msgg%>
            </span><br>
            <% } else{%>
                <span></span>
                <%}%>
                    <button disabled>登录</button>
    </form>
    <script>
        let btn = document.querySelector('button')
        let ipts = document.querySelectorAll('input')
        let span = document.querySelector('span')
        ipts[2].onblur = () => {
            if (ipts[1].value == ipts[2].value) {
                btn.disabled = false
                span.innerHTML = ''

            }
            if (ipts[0].value == ''||ipts[1].value==''||ipts[2].value=='') {
                btn.disabled = true
            }
            else if(ipts[1].value != ipts[2].value) {
                btn.disabled = true
                span.innerHTML = '两次输入密码不一致'
            }
        }

    </script>
</body>

</html>